<?php

use yii\helpers\Html;
use metronic\grid\GridView;

/* @var $model common\models\Category */
?>

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        
        'title',
        'display_order',
        'bookNumber',
        [
            'class' => 'metronic\grid\ActionColumn',
            'template' => '{update} {delete} {up} {check}',
            'buttons' => [
                'view' => function ($url, $model) {
                    return Html::actionButton('查看', ['category-book/index', 'id' => $model->id], 'eye', 'blue', ['title' => '查看该推荐位的作品列表']);
                },
                'delete' => function ($url, $model) {
                    $options = ['data-confirm' => '您确定要删除该推荐位吗？', 'data-method' => 'delete'];
                    if ($model->bookNumber != 0) {
                        $options = ['class' => 'disabled'];
                    }
                    return Html::actionButton('删除', $url, 'trash-o', 'dark', $options);
                },
                'up' => function($url, $model) {
                    return Html::a('<i class="fa fa-arrow-up">置顶</i>', ['/category/up', 'id' => $model->id], ['class' => 'btn btn-outline btn-circle btn-xs blue']);
                },
                'check' => function ($url, $model) {
                    return Html::actionButton('查看书籍', ['book/index', 'cat' => $model->id], 'eye', 'dark');
                }
            ],
        ],

    ],
]); ?>
